/*
 * EquipmentType.cpp
 *
 *  Created on: Oct 8, 2011
 *  Created by: Devin Manno
 *  Updated by: Devin Manno, Nick James
 *	Last Update: Oct 19, 2011
 */

#include "EquipmentType.h"

EquipmentType::EquipmentType() : Base("Equipment") {
	ItemStats.setStats(0, 0, 0, 0, 0, 0);
	srand(time(NULL));
	int generateItem = rand() % 6;
	switch (generateItem){
	case 0:
		generateHelmet();		// generates a helmet
		break;
	case 1:
		generateChest();		// generates chest armor
		break;
	case 2:
		generateGloves();		// generates gloves
		break;
	case 3:
		generateBoots();		// generates boots
		break;
	case 4:
		generatePants();		// generates pants
		break;
	case 5:
		generateWeapon();		// generates a weapon
		break;
	default:
		break;
	}
}

EquipmentType::~EquipmentType(){

}

int EquipmentType::getItemType()const{
	return itemType;	 
}

const Stats &EquipmentType::getItemStats()const{
	return ItemStats;
}

/* Finds ratio between level of item picked and size of vector it came from.  Level is
 * the position in the vector the item was in.  Items are stored in accending order.
 * It then multiplies this ratio to the maxBoost to find the new upper limit on the 
 * amount of points this item can boost your stats. The higher the ratio, the higher
 * the upper limit will be.  The new upper limit will never go beyond maxBoost, 
 * so the range will always be level to upperCap
 */ 
void EquipmentType::generate(int level, int size){
	float ratio;
	int upperCap;
	// prevent divide by 0 and get better ratio
	level++;
	
	ratio = level/size;
	// prevent ratio from going over 1 so final
	// number wont go above maxBoost
	if(ratio > 1)
		ratio = 1;
	upperCap = int(maxBoost*ratio) - level;

	ItemStats.setAgility(level + (rand()% upperCap + 1));
	ItemStats.setStrength(level + (rand()% upperCap + 1));
	ItemStats.setIntelligence(level + (rand()% upperCap + 1));
	ItemStats.setConcentration(level + (rand()% upperCap + 1));
	ItemStats.setMaxHitPoints(level + (rand()% upperCap + 1));
	ItemStats.setMaxActionPoints(level + (rand()% upperCap + 1));
}	


void EquipmentType::generateHelmet(){
	 std::vector<std::string> description; // helmet descriptions
       	description.push_back("Salad Bowl");	
       	description.push_back("Rusty Helmet");	
       	description.push_back("Steel Helmet");	
       	description.push_back("Super Helmet");	
	itemType = HEAD;
	
	srand(time(NULL));				// seed rand function
	long selector = rand() % description.size(); 	// pick a helmet
	setDesc(description[selector]);
	generate(selector,description.size());	

}

void EquipmentType::generateChest(){
	std::vector<std::string> description; // helmet descriptions
       	description.push_back("Leather Vest");	
       	description.push_back("Chain Mesh");	
       	description.push_back("Steel Plate");	
       	description.push_back("Force Field");	
	itemType = CHEST;
	
	srand(time(NULL));				// seed rand function
	long selector = rand() % description.size(); 	// pick a helmet
	setDesc(description[selector]);
	generate(selector,description.size());	

}
void EquipmentType::generateGloves(){
	std::vector<std::string> description; // helmet descriptions
       	description.push_back("Cotton Mittens");	
       	description.push_back("Leather Gloves");	
       	description.push_back("Spiked Gloves");	
       	description.push_back("Brass Knuckles");	
	itemType = GLOVES;
	
	srand(time(NULL));				// seed rand function
	long selector = rand() % description.size(); 	// pick a helmet
	setDesc(description[selector]);
	generate(selector,description.size());	

}

void EquipmentType::generateBoots(){
	std::vector<std::string> description; // helmet descriptions
       	description.push_back("Paper Bags");	
       	description.push_back("Clogs");	
       	description.push_back("Biker Boots");	
       	description.push_back("Jordans");	
	itemType = FEET;
	
	srand(time(NULL));				// seed rand function
	long selector = rand() % description.size(); 	// pick a helmet
	setDesc(description[selector]);
	generate(selector,description.size());	

}

void EquipmentType::generatePants(){
	std::vector<std::string> description; // helmet descriptions
       	description.push_back("Swim Trunks");	
       	description.push_back("Parachute Pants");	
       	description.push_back("Levis");	
       	description.push_back("Diamond Pants");	
	itemType = PANTS;
	
	srand(time(NULL));				// seed rand function
	long selector = rand() % description.size(); 	// pick pants
	setDesc(description[selector]);
	generate(selector,description.size());	

}

void EquipmentType::generateWeapon(){
	std::vector<std::string> description; // helmet descriptions
       	description.push_back("Fuzzy Dice");	
       	description.push_back("Wooden Stick");	
       	description.push_back("Wooden Mallet");	
       	description.push_back("Steel Sword");	
       	description.push_back("Diamond Sword");	
       	description.push_back("Flaming Electrical Sword");	
	itemType = WEAPON;
	
	srand(time(NULL));				// seed rand function
	long selector = rand() % description.size(); 	// pick a weapon
	setDesc(description[selector]);
	generate(selector,description.size());	

}

/*
std::string EquipmentType::getClassName()const{
	return "EquipmentType";
}
*/
